﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FinalMoviles
{
    public partial class Pedidos : Form
    {
        public Pedidos()
        {
            InitializeComponent();
        }

        private void txtNoFact_TextChanged(object sender, EventArgs e)
        {

        }

        private void tabPage2_Click(object sender, EventArgs e)
        {

        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            Menu fact = new Menu();
            this.Hide();
            fact.ShowDialog();
            this.Show();
        }

        swDatos.Service Servicio = new swDatos.Service();
        int pedido;
        private void btnConsultaPed_Click(object sender, EventArgs e)
        {
            if (txtNoPedido.Text == "")
            {
                MessageBox.Show("Favor de Escribir un numero de Pedido");
            }
            else
            {
                pedido = Convert.ToInt32(txtNoPedido.Text);
                DataTable dt;
                dt = Servicio.ObtenerTodosPedidos(clsGlobales.Global_cve_cia, clsGlobales.Global_cve_cte, pedido);
                if (dt.Rows.Count > 0)
                {
                    dtPedido.DataSource = dt;
                }
                else
                {
                    MessageBox.Show("No hay pedidos");
                }
            }
        }

        private void dtPedido_Click(object sender, EventArgs e)
        {
            DataTable dt;
            dt = Servicio.ObtenerDetallePedido(Convert.ToInt16(dtPedido[dtPedido.CurrentRowIndex, 0].ToString()));
            dtHistoPed.DataSource = dt;
        }
    }
}